<?php
/**
 * Created by PhpStorm.
 * User: yandian
 * Date: 16/8/7
 * Time: 14:35
 */

namespace app\weixin\widget;


use app\common\util\weixin\JsApiTool;
use think\Controller;

class WxJsApi extends Controller
{
    public function inviteShared($uid)
    {

    }

    public function shared($title = '', $desc = '', $sharedimg = '', $sharedurl = '')
    {
        if (!ccnn_is_weixin_request()) {
            return '';
        }
        if (empty($title)) {
            $title = ' ';
        }
        if (empty($desc)) {
            $desc = ' ,欢迎加入, ,哈哈～ \(￣▽￣)/ ye~~~~~';
        } else {
            $desc = str_replace('"', '\"', str_replace("\n", '', strip_tags($desc)));
            $desc = str_replace('\\', '\\\\', $desc);
            $desc = ccnn_cutstring($desc, 50);
        }
        if (empty($sharedimg)) {
            $sharedimg = ccnn_request_baseurl() . '/static/img/logo.png';
        }
        if (empty($sharedurl)) {
            $sharedurl = U('index/index', '', true, true);
        }
        $this->assign('jsSignPack', JsApiTool::getSignPackage());
        $this->assign('info', [
                'title' => ccnn_qoute($title),
                'desc' => ccnn_qoute($desc),
                'sharedimg' => $sharedimg,
                'sharedurl' => $sharedurl]
        );
        return $this->fetch('widget/shared');
    }
}